//
//  SEIllManagerHeadView.m
//  kuaiyi
//
//  Created by 蒋小哥 on 16/7/7.
//  Copyright © 2016年 Alphts. All rights reserved.
//

#import "SEIllManagerHeadView.h"

@implementation SEIllManagerHeadView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI {

    //设置headView的子控件
    UIImageView * imgV_photo = [[UIImageView alloc]init];
    imgV_photo.image = [UIImage imageNamed:@"good_image_default"];
    [self addSubview:imgV_photo];
    
    UILabel * lb_name = [[UILabel alloc]init];
    lb_name.text = @"王二狗";
    lb_name.font = FONT(17);
    lb_name.textAlignment = NSTextAlignmentCenter;
    [self addSubview:lb_name];
    
    UIStackView * stackView = [[UIStackView alloc]init];
    [stackView addArrangedSubview:[self addImageViewWithName:@"0"]];
    [stackView addArrangedSubview:[self addImageViewWithName:@"idCard"]];
    [stackView addArrangedSubview:[self addImageViewWithName:@"phone"]];
    [stackView addArrangedSubview:[self addImageViewWithName:@"illness_rb_img_sel.png"]];
    
    stackView.axis = UILayoutConstraintAxisVertical;
    stackView.distribution = UIStackViewDistributionFillEqually;
    stackView.spacing = 15;
    [self addSubview:stackView];
    
    UILabel * lb_gender = [UILabel new];
    lb_gender.text = @"男";
    [self addSubview:lb_gender];
    
    UILabel * lb_age = [UILabel new];
    lb_age.text = @"28";
    [self addSubview:lb_age];
    
    UILabel * lb_idcard = [UILabel new];
    lb_idcard.text = @"2342342342342";
    [self addSubview:lb_idcard];
    
    UILabel * lb_phoneNum = [UILabel new];
    lb_phoneNum.text = @"13157132432";
    [self addSubview:lb_phoneNum];
    
    UILabel * lb_local = [UILabel new];
    lb_local.text = @"上海";
    [self addSubview:lb_local];
    
    //设置约束
    [imgV_photo makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self).offset(20);
        make.left.equalTo(self).offset(20);
        make.bottom.equalTo(self).offset(- 50);
        make.width.equalTo(80);
    }];
    
    [lb_name makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(imgV_photo.bottom).offset(10);
        make.left.right.equalTo(imgV_photo);
        make.height.equalTo(30);
    }];
    
    [stackView makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(imgV_photo);
        make.width.equalTo(14);
        make.left.equalTo(imgV_photo.right).offset(15);
    }];
    
    [lb_gender makeConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(20);
        make.top.equalTo(stackView.top).offset(-4);
        make.left.equalTo(stackView.right).offset(10);
        make.width.equalTo(30);
    }];
    
    [lb_age makeConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(20);
        make.top.equalTo(lb_gender);
        make.left.equalTo(lb_gender.right).offset(10);
    }];
    
    [lb_idcard makeConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(20);
        make.top.equalTo(lb_gender.bottom).offset(10);
        make.left.equalTo(lb_gender);
    }];
    
    [lb_phoneNum makeConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(20);
        make.top.equalTo(lb_idcard.bottom).offset(10);
        make.left.equalTo(lb_gender);
    }];
    
    [lb_local makeConstraints:^(MASConstraintMaker *make) {
        
        make.height.equalTo(20);
        make.top.equalTo(lb_phoneNum.bottom).offset(10);
        make.left.equalTo(lb_gender);
    }];
}

- (UIImageView *)addImageViewWithName:(NSString *)imgName {
    UIImageView * imageView = [[UIImageView alloc]init];
    imageView.image = [UIImage imageNamed:imgName];
    return imageView;
}
@end
